package com.unswift.utils;

import java.net.InetAddress;

import com.unswift.annotation.api.Api;
import com.unswift.annotation.api.ApiField;
import com.unswift.annotation.api.ApiMethod;

@Api(value="java系统相关操作", author="unswift", date="2023-04-16", version="1.0.0")
public final class SystemUtils {

	@ApiMethod(value="获取操作系统当前用户名称", returns=@ApiField("用户名称"))
	public static String getSystemName(){
		return System.getProperty("user.name");
	}
	
	public static String getHostIp(){
		try {
			InetAddress localHost = InetAddress.getLocalHost();
			return localHost.getHostAddress();
		} catch (Exception e) {
			e.printStackTrace();
			throw ExceptionUtils.exception("get.host.ip.exception", e, e.getMessage());
		}
	}
}
